package com.mapper;

import com.mapper.Users;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * @author 21539
 * @description 针对表【users】的数据库操作Mapper
 * @createDate 2024-11-06 17:09:36
 * @Entity com.mapper.Users
 */

public interface UserMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Users record);

    int insertSelective(Users record);

    Users selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Users record);

    int updateByPrimaryKey(Users record);

    @Select("select * from tb_user where id=#{id}")
    @Results(value = {@Result(id = true,column = "id",property = "id"),
            @Result(column = "username",property = "username"), @Result(column = "address", property = "address"),
            @Result(column = "id",property = "ordersList",many = @Many(select = "com.mapper.OrdersMapper.selectOrdersByUserId"))})
    Users selectUserById(int id);



}

